package leetcode.tree;

import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution250 {
    public int countUnivalSubtrees(TreeNode root) {
        return TreeUtils.countUnivalSubtrees(root);
    }
}

public class leetcode250 {
    public static void main(String[] args) {
        Solution250 solution250 = new Solution250();
        Integer[] nums = {5, 1, 5, 5, 5, null, 5};
        System.out.println(solution250.countUnivalSubtrees(TreeUtils.generateLeetcodeTree(nums)));
    }
}
